<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>登陆</title>
  <!-- Bootstrap core CSS-->
  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom fonts for this template-->
  <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <!-- Custom styles for this template-->
  <link href="css/sb-admin.css" rel="stylesheet">
</head>

<body class="bg-dark">
  <div class="container">
    <div class="card card-login mx-auto mt-5">
      <div class="card-header">登录</div>
      <div class="card-body">
        <form>
          <div class="form-group">
            <label for="tel">手机号</label>
            <input class="form-control" id="tel" name="tel" type="email" aria-describedby="emailHelp" placeholder="phonenumer" required="required">
            <span id="msg" style="color:royalblue;"></span>
          </div>
          <div class="form-group">
            <label for="password">密码</label>
            <input class="form-control" id="password" name="password" type="password" placeholder="Password" required="required">
            <span id="msg1" style="color:royalblue;"></span>
          </div>
          <div class="form-group">
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="checkbox">记住密码</label>
            </div>
          </div>
         <!-- <a class="btn btn-primary btn-block" href="index.html">登陆</a>-->
          <input type="button" name="btn" id="btn" value="登陆" class="btn btn-primary btn-block"/>
          <div id="box" style="color:red;"></div>
        </form>
        <div class="text-center">
          <a class="d-block small mt-3" href="register.html">注册账号</a>
          <a class="d-block small" href="forgot-password.html">忘记密码?</a>
        </div>
      </div>
    </div>
  </div>
  <!-- Bootstrap core JavaScript-->
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="vendor/popper/popper.min.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
  <!-- Core plugin JavaScript-->
  <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
</body>
	<script type="text/javascript">
		$(function(){
			  
			$('#btn').on('click', function(){
				var username = $('#tel').val();
				var password = $('#password').val();
				$.ajax({
					type:"get",
					url:"http://localhost:3000/admin/login",
					data:{
						username:username,
						password:password
					},
					success: function (data){
						console.log(data);
						if(data == "1"){//1表示登陆成功
//							alert(1)
							window.location.href = "http://127.0.0.1/A-Sweetown/最后一阶段/project/Personnel%20Management%20System/index.html";
						}else if(data == "0"){//0表示信息错误
							$('#box').html('信息错误');
						}
					}
				});
			})

			var oReg = /^1\d{10}$/;
			$('#tel').blur(function(){
				if(oReg.test($('#tel').val())){
					$('#msg').html('手机号正确');
				}else{
					$('#msg').html('请输入正确的手机号');
				}
			})
			var oReg1 = /^[a-zA-Z0-9]{4,16}$/;
			$('#password').blur(function(){
				if(oReg1.test($('#password').val())){
					$('#msg1').html('密码正确');
				}else{
					$('#msg1').html('请输入正确的密码');
				}
			})
			
		})
	</script>
</html>
